// A class implements interfaces
{
  interface Alarm {
    alert(): void;
  }

  interface Light {
    lightOn(): void;
    lightOff(): void;
  }

  class Door {}

  class SecurityDoor extends Door implements Alarm {
    alert(): void {
      console.log("SecurityDoor alert");
    }
  }

  class Car implements Alarm, Light {
    alert(): void {
      console.log("Car alert");
    }

    lightOn(): void {
      console.log("Car light on");
    }

    lightOff(): void {
      console.log("Car light off");
    }
  }
}

// An interface extends interfaces
{
  interface Alarm {
    alert(): void;
  }

  interface LightableAlarm extends Alarm {
    lightOn(): void;
    lightOff(): void;
  }
}

// An interface extends a class
{
  class Point {
    public static origin = new Point(0, 0);
    public static distanceToOrigin(p: Point) {
      return Math.sqrt(p.x * p.x + p.y * p.y);
    }

    x: number;
    y: number;
    constructor(x: number, y: number) {
      this.x = x;
      this.y = y;
    }
  }

  interface Point3d extends Point {
    z: number;
  }

  let point3d: Point3d = { x: 1, y: 2, z: 3 };
  // point3d.origin;
  // point3d.distanceToOrigin(new Point(3, 4));
}
